<template>
  <div class="dashboard-container">
    <div class="page-header">
      <h2>仪表盘</h2>
      <div class="header-actions">
        <button class="btn-primary">刷新数据</button>
      </div>
    </div>
    
    <div class="dashboard-grid">
      <div class="stats-card">
        <div class="stats-icon">📊</div>
        <div class="stats-content">
          <h3>总知识数</h3>
          <p class="stats-number">1,256</p>
          <span class="stats-change positive">+12%</span>
        </div>
      </div>
      
      <div class="stats-card">
        <div class="stats-icon">👥</div>
        <div class="stats-content">
          <h3>活跃用户</h3>
          <p class="stats-number">89</p>
          <span class="stats-change positive">+5%</span>
        </div>
      </div>
      
      <div class="stats-card">
        <div class="stats-icon">❓</div>
        <div class="stats-content">
          <h3>问答次数</h3>
          <p class="stats-number">2,341</p>
          <span class="stats-change positive">+18%</span>
        </div>
      </div>
      
      <div class="stats-card">
        <div class="stats-icon">📈</div>
        <div class="stats-content">
          <h3>系统使用率</h3>
          <p class="stats-number">94%</p>
          <span class="stats-change negative">-2%</span>
        </div>
      </div>
    </div>
    
    <div class="dashboard-content">
      <div class="chart-section">
        <h3>知识增长趋势</h3>
        <div class="chart-placeholder">
          <p>图表将在此处显示</p>
        </div>
      </div>
      
      <div class="recent-activity">
        <h3>最近活动</h3>
        <div class="activity-list">
          <div class="activity-item">
            <span class="activity-icon">📝</span>
            <div class="activity-content">
              <p>用户 张三 创建了新知识</p>
              <span class="activity-time">2分钟前</span>
            </div>
          </div>
          <div class="activity-item">
            <span class="activity-icon">❓</span>
            <div class="activity-content">
              <p>用户 李四 提出了新问题</p>
              <span class="activity-time">5分钟前</span>
            </div>
          </div>
          <div class="activity-item">
            <span class="activity-icon">✅</span>
            <div class="activity-content">
              <p>知识审核通过</p>
              <span class="activity-time">10分钟前</span>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
// 仪表盘组件逻辑
</script>

<style scoped>
.dashboard-container {
  padding: 0;
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.page-header h2 {
  color: var(--text-primary);
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
}

.btn-primary {
  background: var(--accent-color);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  cursor: pointer;
  font-weight: 500;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stats-card {
  background: var(--bg-primary);
  color: var(--text-primary);
  border-radius: 0.75rem;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  gap: 1rem;
}

.stats-icon {
  font-size: 2rem;
  width: 3rem;
  height: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  border-radius: 0.5rem;
}

.stats-content {
  flex: 1;
}

.stats-content h3 {
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  margin: 0 0 0.5rem 0;
}

.stats-number {
  color: var(--text-primary);
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 0.25rem 0;
}

.stats-change {
  font-size: 0.75rem;
  font-weight: 500;
}

.stats-change.positive {
  color: #059669;
}

.stats-change.negative {
  color: #dc2626;
}

.dashboard-content {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 2rem;
}

.chart-section,
.recent-activity {
  background: var(--bg-primary);
  color: var(--text-primary);
  border-radius: 0.75rem;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.chart-section h3,
.recent-activity h3 {
  color: var(--text-primary);
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0 0 1rem 0;
}

.chart-placeholder {
  height: 200px;
  background: var(--bg-tertiary);
  border: 2px dashed var(--border-color);
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

.activity-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.activity-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--bg-tertiary);
  border-radius: 0.5rem;
}

.activity-icon {
  font-size: 1.25rem;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  border-radius: 0.375rem;
}

.activity-content {
  flex: 1;
}

.activity-content p {
  color: var(--text-primary);
  font-size: 0.875rem;
  margin: 0 0 0.25rem 0;
}

.activity-time {
  color: var(--text-secondary);
  font-size: 0.75rem;
}

@media (max-width: 768px) {
  .dashboard-content {
    grid-template-columns: 1fr;
  }
  
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}
</style>
